/*
 *  Class name: PersonValidator.java
 *  Version: 1.0
 *  Date: 3.6.2014
 */
package cz.muni.fi.pv168.addressbook.entities.validators;

import cz.muni.fi.pv168.addressbook.entities.Person;

/**
 *
 * @author Michal Ďuriš
 */
public class PersonValidator extends Validator<Person> {

    public PersonValidator() {
    }

    @Override
    protected void testID(Person entity) throws IllegalArgumentException {

        testToNull(entity);

        if (!Validator.CORRECT_ID_PREDICATE.test(entity.getId())) {
            throw new IllegalArgumentException();
        }
    }

    @Override
    protected void testRequiredFields(Person entity) throws
            IllegalArgumentException {

        testToNull(entity);

        if (!Validator.NOT_EMPTY_STRING_PREDICATE.test(entity.getLastName())) {
            throw new IllegalArgumentException();
        }
    }
}
